<!DOCTYPE html>
<html>
<head>
    <th:block th:include="include :: header('修改密码-互助保障系统V3')"/>
</head>
<body>
<div class="page">
    <th:block th:include="include :: unLoginTop"/>

    <div class="center">
        <div class="page-content">
            <div class="page-forgot-password">
                <h2>修改密码</h2>
                <form class="page-form">
                    <input type="hidden" name="id" value="${hzUnit.id}"/>
                    <div class="page-form-item">
                        <div class="page-form-label">旧密码：</div>
                        <div class="page-form-input">
                            <input type="password" style="width:150px" name="oldpassword" id="oldpassword"/>
                        </div>
                    </div>
                    <div class="page-form-item">
                        <div class="page-form-label">新密码：</div>
                        <div class="page-form-input">
                            <input type="password" style="width:150px" name="newpassword" id="newpassword"/>
                        </div>
                    </div>
                    <div class="page-form-item">
                        <div class="page-form-label">确认密码：</div>
                        <div class="page-form-input">
                            <input type="password" style="width:150px" name="confirmpassword" id="confirmpassword"/>
                        </div>
                    </div>
                    <div class="page-form-item">
                        <div class="page-form-label"></div>
                        <div class="page-form-input">
                            <a class="layui-btn">立即修改</a>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer"/>
</div>

<script src="/footerjs.js"></script>

<script type="text/javascript">
    $(".layui-btn").click(function () {
        var oldpassword = $("#oldpassword").val();
        var newpassword = $("#newpassword").val();
        var confirmpassword = $("#confirmpassword").val();
        if (!oldpassword) {
            layer.msg("请输入旧密码！");
        } else if (!newpassword) {
            layer.msg("请输入新密码！");
        } else if (!confirmpassword) {
            layer.msg("请输入确认密码！");
        } else {
            var idx = layer.load(0);
            $.ajax({
                url: "/unit/updateUnitPassword",
                data: $(".page-form").serialize(),
                success: function (data) {
                    layer.close(idx);
                    if (data.success) {
                        layer.msg("更新成功");
                    } else {
                        layer.msg(data.msg);
                    }
                }
            });
        }
    });
</script>

</body>
</html>